package com.example.demo.vo

import com.example.demo.dbmodels.TFood
import io.swagger.annotations.ApiModelProperty

class FoodVo {


    @ApiModelProperty(value = "id")
    var id: Int? = null

    @ApiModelProperty(value = "菜品名称")
    var title: String? = null

    @ApiModelProperty(value = "图片url")
    var url: String? = null

    @ApiModelProperty(value = "价格")
    var price: Double? = null

    @ApiModelProperty(value = "销量")
    var sales: Int? = null

    @ApiModelProperty(value = "菜品简介")
    var Introduction: String? = null

    @ApiModelProperty(value = "规格")
    var specification: String? = null

    @ApiModelProperty(value = "菜品id")
    var foodTypeId: Int? = null


    fun getVo(table: TFood): FoodVo {
        table.let {
            val data = FoodVo()
            data.id = it.id
            data.Introduction = it.Introduction
            data.foodTypeId = it.foodTypeId
            data.price = it.price
            data.sales = it.sales
            data.specification = it.specification
            data.title = it.title
            data.url = it.url
            return data
        }
    }

    fun getListVo(table: List<TFood>): List<FoodVo>  {
        table.let {
            val listFoodVo = mutableListOf<FoodVo>()
            it.forEach {
                val data = FoodVo()
                data.id = it.id
                data.Introduction = it.Introduction
                data.foodTypeId = it.foodTypeId
                data.price = it.price
                data.sales = it.sales
                data.specification = it.specification
                data.title = it.title
                data.url = it.url
                listFoodVo.add(data)
            }
            return listFoodVo
        }
    }


}